<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');

$id = abs(intval($_GET['id']));

$order = Table::Fetch('order', $id);
if (!$order) { 
	Session::Set('error', '订单不存在');
	redirect( WEB_ROOT . '/index.php' );
}

// 成功获取到优惠券
if($order['state'] == 'unpay'){
	Table::UpdateCache('order', $id, array('state' => 'sync'));
	$order = Table::FetchForce('order', $id);
	ZTeam::BuyOne($order);
}

$team = Table::Fetch('team', $order['team_id']);
include template('order_synced');